package com.yingxue.lesson.service.impl;

import com.alibaba.fastjson.JSON;
import com.yingxue.lesson.entity.SysUser;
import com.yingxue.lesson.mapper.SysUserMapper;
import com.yingxue.lesson.service.HomeService;
import com.yingxue.lesson.service.PermissionService;
import com.yingxue.lesson.vo.resp.HomeRespVO;
import com.yingxue.lesson.vo.resp.PermissionRespNodeVO;
import com.yingxue.lesson.vo.resp.UserInfoRespVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @ClassName: HomeServiceImpl
 * TODO:类文件简单描述
 * @Author: 小霍
 * @UpdateUser: 小霍
 * @Version: 0.0.1
 */
@Service
public class HomeServiceImpl implements HomeService {
    @Autowired
    private SysUserMapper sysUserMapper;
    @Autowired
    private PermissionService permissionService;

    @Override
    public HomeRespVO getHome(String userId) {
        HomeRespVO homeRespVO=new HomeRespVO();
        /**
         * mock 导航菜单数据后期直接从DB获取
         */



        List<PermissionRespNodeVO> list= permissionService.permissionTreeList(userId);
        homeRespVO.setMenus(list);
        SysUser sysUser=sysUserMapper.selectByPrimaryKey(userId);


        UserInfoRespVO respVO=new UserInfoRespVO();

        if(sysUser!=null){
            respVO.setUsername(sysUser.getUsername());
            respVO.setDeptName("迎学教育");
            respVO.setId(sysUser.getId());
        }
           homeRespVO.setUserInfoVO(respVO);
        return homeRespVO;

    }
}





